Not all development environments support ActiveX designers. Visual C++ and Delphi, for example, are two environments where you can use the functionality of the RDC automation server but you can't add the RDC directly to your projects. In these cases, you must access the Report Designer's Report object by creating an instance of the Application object and then calling the OpenReport method as well.
In other situations, you may need to use separate report files in your application that were created or edited using Crystal Reports. An advantage of using such standalone report files is that through Crystal Reports, you can save report data with the report file, eliminating the need of maintaining a connection to a data source at runtime. In this case you will need to create an instance of the Application object and then call the OpenReport method as well.
The following code sample demonstrates the process of obtaining an Application object and opening a report file in Visual Basic:
Dim CRXApplication As CRAXDRT.Application
Dim CRXReport As CRAXDRT.Report
Private Sub Form_Load()
Set CRXApplication = CreateObject("CrystalRuntime.Application")
Set CRXReport = CRXApplication.OpenReport("C:\Reports\Sales.rpt")
End Sub
When this code finishes, rpt is a valid Report object and can be used just like any Report object you would obtain through the Report Designer Component.
Note: The sample call to CreateObject above uses a version independent Prog Id for the Report Designer Component. The correct Prog Id for this version of the Report Designer Component is CrystalRuntime.Application.8, but the version independent Prog Id should use the most recent version of the component installed on your system.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |